package cn.yyh.serviceOrg.utils;

import cn.yyh.serviceOrg.entity.User;

import java.util.Date;
import java.util.LinkedHashMap;


/**
 * 实体转化工具类ConvertUtils
 *
 * @version: 1.0
 * @return: null
 * @author: 杨永航
 * @date: 2021/7/11
 */
public class ConvertUtils {
    public static User convertInfoToToUserInfo(LinkedHashMap<Object, Object> info) {
        User user = new User();
        if ((info != null) && (!info.isEmpty())) {
            user.setId(Long.valueOf(String.valueOf(info.get("id"))));
            user.setUsername(String.valueOf(info.get("username")));
            user.setEmail(String.valueOf(info.get("email")));
            user.setPhone(String.valueOf(info.get("phone")));
            user.setSalt(String.valueOf(info.get("salt")));
            user.setPassword(String.valueOf(info.get("password")));
            user.setState(Integer.valueOf(String.valueOf(info.get("state"))));
            user.setAge(Integer.valueOf(String.valueOf(info.get("age"))));
            user.setCreateTime(new Date(String.valueOf(info.get("createTime"))));
            user.setHeadImg(String.valueOf(info.get("headImg")));
            user.setLoginInfoId(Long.valueOf(String.valueOf(info.get("loginInfoId"))));
            return user;
        }
        return null;
    }
}
